package com.usian.wemedia.controller.v1;

import com.usian.apis.media.WmMaterialControllerApis;
import com.usian.common.wemedia.WemediaContants;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmMaterialDto;
import com.usian.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController implements WmMaterialControllerApis {

    @Autowired
    private WmMaterialService wmMaterialServiceI;
    @PostMapping("upload_picture")
    @Override
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        return wmMaterialServiceI.uploadPicture(multipartFile);
    }

    @Override
    @PostMapping("list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto) {

        return wmMaterialServiceI.findList(dto);
    }

    @Override
    @GetMapping("del_picture/{id}")
    public ResponseResult delWmMaterial(@PathVariable Integer id) {
        return wmMaterialServiceI.delWmMaterial(id);
    }

    @Override
    @GetMapping("collect/{id}")
    public ResponseResult collectWmMaterial(@PathVariable Integer id) {

        return wmMaterialServiceI.collect(id, WemediaContants.COLLECT_MATERIAL);
    }

    @Override
    @GetMapping("cancel_collect/{id}")
    public ResponseResult cancelCollectWmMaterial(@PathVariable Integer id) {
        return wmMaterialServiceI.collect(id, WemediaContants.CANCEL_COLLECT_MATERIAL);
    }
}
